﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
namespace _2014112107
{
    public partial class UserChangePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnChange_Click(object sender, EventArgs e)
        {
            string strCn = "server=pc.hstc.cn;database=dhd2014112107;uid=2014112107;pwd=19951106";
            SqlConnection cn = new SqlConnection(strCn);
            try
            {
                cn.Open();
                //string strUserName = this.txtUserName.Text;
                //忽略检测规范
                string strSql = "UPDATE  UserInfo     SET  Password= '" + this.txtNewPwd.Text + "'   WHERE  (UserName = N'" + this.txtUserName.Text+"') ";
                SqlCommand cmd = new SqlCommand(strSql, cn);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    this.txtNewPwd.Text = dr["Password"].ToString();

                }
                Response.Write("<script>alert('更改密码成功!')</script>");
                
            }
            catch (Exception ex)
            {
                this.lblInfo.Text = ex.Message;
            }
            finally
            {
                cn.Close();
            }
        }
    }
}